import { _decorator, Component, Node } from 'cc';
import { GGStore } from '../../../framework/core/base/GGStore';
import { GAME_DATA_ENUMS } from './Enums';
const { ccclass, property } = _decorator;

export default class DataMgr {
    // 当前选择槽的最大数量
    static currentMaxSlotCount: number = 8
    
    // =======================================
    // Component Set Get 用来保存本地数据
    // =======================================
    // 邀请次数
    private static _inviteCount = null
    public static set inviteCount(v: number) {
        DataMgr._inviteCount = v
        GGStore.set(GAME_DATA_ENUMS.INVITE_COUNT, DataMgr._inviteCount)
    }
    public static get inviteCount(): number {
        if (DataMgr._inviteCount == null) {
            DataMgr._inviteCount = GGStore.get(GAME_DATA_ENUMS.INVITE_COUNT, 1)
        }

        return DataMgr._inviteCount
    }

    // 当前关卡
    private static _currentLevel = null
    public static set currentLevel(v: number) {
        DataMgr._currentLevel = v
        GGStore.set(GAME_DATA_ENUMS.SAVE_LEVEL, DataMgr._currentLevel)
    }
    public static get currentLevel(): number {
        if (DataMgr._currentLevel == null) {
            DataMgr._currentLevel = GGStore.get(GAME_DATA_ENUMS.SAVE_LEVEL, 1)
        }

        return DataMgr._currentLevel
    }

    // 金币
    private static _money = null
    public static set money(v: number) {
        DataMgr._money = v
        GGStore.set(GAME_DATA_ENUMS.SAVE_MONEY, DataMgr._money)
    }
    public static get money(): number {
        if (DataMgr._money == null) {
            DataMgr._money = GGStore.get(GAME_DATA_ENUMS.SAVE_MONEY, 0)
        }

        return DataMgr._money
    }

    // 体力
    private static _stamina = null
    public static set stamina(v: number) {
        DataMgr._stamina = v
        GGStore.set(GAME_DATA_ENUMS.SAVE_STAMINA, DataMgr._stamina)
    }
    public static get stamina(): number {
        if (DataMgr._stamina == null) {
            DataMgr._stamina = GGStore.get(GAME_DATA_ENUMS.SAVE_STAMINA, 0)
        }

        return DataMgr._stamina
    }

    // ------------------- 道具数量 ------------------- //
    // 洗牌
    private static _washCount = null
    public static set washCount(v: number) {
        DataMgr._washCount = v
        GGStore.set(GAME_DATA_ENUMS.WASH_PROPERTY_COUNT, DataMgr._washCount)
    }
    public static get washCount(): number {
        if (DataMgr._washCount == null) {
            DataMgr._washCount = GGStore.get(GAME_DATA_ENUMS.WASH_PROPERTY_COUNT, 0)
        }

        return DataMgr._washCount
    }
    
    // 移除
    private static _removeCount = null
    public static set removeCount(v: number) {
        DataMgr._removeCount = v
        GGStore.set(GAME_DATA_ENUMS.REMOVE_PROPERTY_COUNT, DataMgr._removeCount)
    }
    public static get removeCount(): number {
        if (DataMgr._removeCount == null) {
            DataMgr._removeCount = GGStore.get(GAME_DATA_ENUMS.REMOVE_PROPERTY_COUNT, 0)
        }

        return DataMgr._removeCount
    }
    
    // 凑齐
    private static _magnetCount = null
    public static set magnetCount(v: number) {
        DataMgr._magnetCount = v
        GGStore.set(GAME_DATA_ENUMS.MAGNET_PROPERTY_COUNT, DataMgr._magnetCount)
    }
    public static get magnetCount(): number {
        if (DataMgr._magnetCount == null) {
            DataMgr._magnetCount = GGStore.get(GAME_DATA_ENUMS.MAGNET_PROPERTY_COUNT, 0)
        }

        return DataMgr._magnetCount
    }
    
    // 加时
    private static _addCount = null
    public static set addCount(v: number) {
        DataMgr._addCount = v
        GGStore.set(GAME_DATA_ENUMS.ADD_PROPERTY_COUNT, DataMgr._addCount)
    }
    public static get addCount(): number {
        if (DataMgr._addCount == null) {
            DataMgr._addCount = GGStore.get(GAME_DATA_ENUMS.ADD_PROPERTY_COUNT, 0)
        }

        return DataMgr._addCount
    }
}

